#ifndef __DBBASE_H__
#define __DBBASE_H__
#include <iostream>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cstdlib>
using namespace std;
#include "dbTree.h"
#include "dbTag.h"
#include "extMD5.h"

namespace db
{

class Base
{
  public:
    Base(TreeVertex* curr = Curr);
    ~Base();
    bool atRoot();
    bool atLeaf();
    void setPass(string pass);

    TreeVertex* addEntry();
    TreeVertex* addEndEntry();
    TreeVertex* addBranch();
    void delCurrentEntry(bool children, bool successor);

    void goTo(TreeVertex* entry);		
    TreeVertex* moveUp();
    TreeVertex* moveDown();
    TreeVertex* moveSide(int id);
    TreeVertex* getCurrent();
    
    static Tag* getTag(string name);
    static Tag* getTag(int id);
    int getTagsCount();
    
    int getCode(int ch);
    int Save(string filename);
    int Load(string filename);

  private:
    static TreeVertex* Root;
    static TreeVertex* Curr;
    static vector<Tag*> Tags;
    static int maxID;
    static string Pass;
};

}

#endif /* __DBBASE_H__ */